package com.ygsoft.tianlu_mall.service.impl;

import com.ygsoft.tianlu_mall.mapper.SearchMapper;
import com.ygsoft.tianlu_mall.pojo.Search;
import com.ygsoft.tianlu_mall.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class SearchServiceImpl implements SearchService {
    @Autowired
    SearchMapper searchMapper;

    @Override
    public List<String> getTop5Hotword() {
        return searchMapper.getTop5Hotword();
    }

    @Override
    public List<String> checkHotwordIsExist() {
        return searchMapper.checkHotwordIsExist();
    }

    @Override
    public void insertHotword(String search_content){
        searchMapper.insertHotword(search_content);
    }

    @Override
    public void updateHotwordCount(String search_content) {
        searchMapper.updateHotwordCount(search_content);
    }

    @Override
    public List<Map<String, Object>> getGoodsDetailByLike(String search_content) {
        return searchMapper.getGoodsDetailByLike(search_content);
    }

    @Override
    public List<Map<String, Object>> getGoodsDetailByLikeInShop(int shop_id,String search_content) {
        HashMap<String,Object> map = new HashMap<>();
        map.put("shop_id",shop_id);
        map.put("search_content",search_content);
        return searchMapper.getGoodsDetailByLikeInShop(map);
    }

    @Override
    public List getGoodsIdBySearchContent(String search_content) {
        return searchMapper.getGoodsIdBySearchContent(search_content);
    }

    @Override
    public List getGoodsIdByShopIdAndSearchContent(int shop_id, String search_content) {
        HashMap<String,Object> map = new HashMap<>();
        map.put("shop_id",shop_id);
        map.put("search_content",search_content);
        return searchMapper.getGoodsIdByShopIdAndSearchContent(map);
    }
}
